﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using proRFID_DiemDanh.Chung;

namespace proRFID_DiemDanh.MonHoc
{
    public partial class SuaMonHoc : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (string.IsNullOrEmpty(Request["ID"]))
                    Response.Redirect("../Monhoc/Monhoc.aspx");
                HienThi();
            }
        }
        void HienThi()
        {
            DataTable dt = new DataTable();
            dt = mdMonHoc.sp_MONHOC_Select(Convert.ToInt32(Request["ID"]));
            txt_TenMH.Text = dt.Rows[0]["TENMH"].ToString();
        }

        protected void Imgcmd_SuaMH_Click(object sender, ImageClickEventArgs e)
        {
            DataTable dt = new DataTable();
            dt = mdMonHoc.sp_MONHOC_Update(Convert.ToInt32(Request["ID"]), txt_TenMH.Text);
            if (dt.Rows[0]["ErrCode"].ToString() == "0")
                mdMain.OKBox(this, dt.Rows[0]["ErrMsg"].ToString(), "/Monhoc/Monhoc.aspx");
            else
                mdMain.OKCancelBox(this, dt.Rows[0]["ErrMsg"].ToString() + ". Bạn có muốn thử lại không?", "/Monhoc/Monhoc.aspx");
        }
    }
}